#ifndef __loggableH__
#define __loggableH__

#include "string.h"
#include "kernel.h"
#include <vector>

namespace WtfEngine
{
	class SystemMessage : public KeyedEvent<SystemMessage> {
		String msMessage;

	public:
		SystemMessage(const String& sMessage)
			: KeyedEvent(), msMessage(sMessage)
		{
		};

		const String& getMessage() const {
			return msMessage;
		};
	};

	class SystemLog : public Singleton<SystemLog>
	{
	public:
		typedef std::pair<tGameTime, String>	tLogItem;

		void OutputLog(const char* sClass, const tLogItem& logItem);
	};

	typedef std::vector<SystemLog::tLogItem>	tLog;

	template <class tClass>
	class Loggable
	{
	public:
		typedef enum{
			LOG_COMMENT = 0,
			LOG_DEBUG,
			LOG_INFO,
			LOG_WARNING,
			LOG_ERROR
		} tLogLevel;

	private:
		static tLog	mLog;
		const char*	msClass;

	public:
		Loggable(const char* sClass){
			msClass = sClass;
		};

		void Log(tLogLevel lvl, const String& sMsg){
			SystemLog::tLogItem logItem(Kernel::GetInstance().GetTime(), sMsg);

			mLog.push_back(logItem);
			SystemLog::GetInstance().OutputLog(msClass, logItem);
		};
	};

	template <class T> tLog Loggable<T>::mLog;
};


#endif
